package cn.wubo.redis.listener;

import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;

import java.io.UnsupportedEncodingException;

public class RedisChannelListener implements MessageListener {
    @Override
    public void onMessage(Message message, byte[] pattern) {
        byte[] channel = message.getChannel();
        byte[] bs = message.getBody();
        try {
            String connect = new String(bs, "UTF-8");
            String p = new String(channel, "UTF-8");
            System.out.print("get " + connect + " from " + p);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }
}
